package com.sinosoft.dsp.platform.action;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.RequestScoped;

import org.primefaces.event.NodeSelectEvent;
import org.primefaces.model.TreeNode;

import com.sinosoft.dsp.platform.components.portal.iteration.ISinoTreeViewBean;
import com.sinosoft.dsp.system.core.log.Log;
import com.sinosoft.dsp.platform.manager.ApplicationController;

/**
 * 树通用行为
 * 
 * @author 潘巍（PeterPan）
 * @since 2011-6-12 下午11:08:51
 * 
 */
@ManagedBean(name = "treeAction")
@RequestScoped
public class TreeAction {

	private static final Log log = Log.getLog(TreeAction.class.getName());

	@ManagedProperty(value = "#{applicationController}")
	private ApplicationController applicationController;

	public void onNodeSelect(NodeSelectEvent event) {
		TreeNode tn = event.getTreeNode();
		while (true) {
			if (tn.getParent() == null) {
				break;
			} else {
				tn = tn.getParent();
			}
		}
		//TODO
//		ISinoTreeViewBean<?> viewBean = (ISinoTreeViewBean<?>) applicationController
//				.getViewBeanById((String) tn.getData());
//		viewBean.onNodeSelect(event);
	}

	public ApplicationController getApplicationController() {
		return applicationController;
	}

	public void setApplicationController(
			ApplicationController applicationController) {
		this.applicationController = applicationController;
	}

}
